package com.blackjack
{
	import com.blackjack.cards.Stack;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;

	public class Game extends Sprite
	{
		public static const CARDPACKS_IN_STACK:int = 6;
		
		private static var _instance:Game;
		private var stackButton:Texture_Stack;
		private var _dealer:Dealer;
		private var _player:Player;
		
		public function Game()
		{
			_instance = this;
			initGame();
			initGUI();
			startgame();
		}
		
		public function startgame():void{
			_dealer.takeCard();
			_player.takeCard();
			_dealer.takeCard();
			_player.takeCard();
		}
		
		public function update():void{
			_player.update();
			_dealer.update();
		}
		
		public function get dealer():Dealer{return _dealer;}
		public function get player():Player{return _player;}
		public static function get instance():Game {return _instance;}
		
		private function initGame():void{
			_dealer = new Dealer();
			_player = new Player();
		}
		
		private function initGUI():void{
			
			stackButton = new Texture_Stack();
			stackButton.x = 700;
			stackButton.y = 20;
			stackButton.buttonMode = true;
			stackButton.addEventListener(MouseEvent.CLICK, mCickOnStack);
			addChild(stackButton);
			
		}
		
		private function resetGame():void{
			Stack.instance.resetStack();
			_player.deck.resetDeck();
			_dealer.deck.resetDeck();
		}
		
		private function mCickOnStack(e:MouseEvent):void{
			_player.takeCard();
		}
		
		private function mCickOnSetMoney(e:MouseEvent):void{
			
		}
		
		private function mCickOnDouble(e:MouseEvent):void{
			
		}
		
		private function mCickOnSplitt(e:MouseEvent):void{
			
		}
		
		private function mCickOnInsurance(e:MouseEvent):void{
			
		}
		
		private function mCickOnStand(e:MouseEvent):void{
			_player.stand = false;
		}
		
		public function setMoney(money:uint):void{
			
		}
		
		public function doubleDown():void{
			
		}
		
		public function splitt():void{
			
		}
		
		public function insurance():void{
			
		}
	}
}